package com.caohx.bms.pojo.dto;

import com.caohx.bms.pojo.Book;
import com.caohx.bms.pojo.BookCategory;
import com.caohx.bms.service.BookCategoryService;


public class BookDto {
    private Long id;
    private String title;
    private String author;
    private long categoryid;
    private String description;
    private Integer stockQuantity;


    public Book trans2Book(BookCategoryService categoryService) {
        Book book = new Book();
        book.setId(this.id);
        book.setTitle(this.title);
        book.setAuthor(this.author);
        book.setDescription(this.description);
        book.setStockQuantity(this.stockQuantity);

        // 根据categoryid查询分类对象
       BookCategory bookCategory =   categoryService.get(this.categoryid);
        book.setCategory(bookCategory);

        return book;
    }

    // Getter和Setter方法
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public long getCategoryid() {
        return categoryid;
    }

    public void setCategoryid(long categoryid) {
        this.categoryid = categoryid;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getStockQuantity() {
        return stockQuantity;
    }

    public void setStockQuantity(Integer stockQuantity) {
        this.stockQuantity = stockQuantity;
    }
}
